////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "WNMemory/inc/WNMemory.h"
#include "WNMath/inc/WNLine3.h"
#include "WNMath/inc/WNVector3.h"

using namespace WNMath;

// Constructors ////////////////////////////////////////////////////////////////////////////////////

WNLine3::WNLine3() :
    point1(0.0f, 0.0f, 0.0f),
    point2(0.0f, 0.0f, 0.0f) {
}

WNLine3::WNLine3(const WN_FLOAT32* _f) :
    point1(_f[0], _f[1], _f[2]),
    point2(_f[3], _f[4], _f[5]) {
}

WNLine3::WNLine3(const WNPoint3& _point1, const WNPoint3& _point2) :
    point1(_point1),
    point2(_point2) {
}

// Operators ///////////////////////////////////////////////////////////////////////////////////////

WNLine3 WNLine3::operator + () const {
    return(*this);
}

WNLine3 WNLine3::operator - () const {
    return(WNLine3(-point1, -point2));
}

WN_BOOL WNLine3::operator == (const WNLine3& _line) const {
    return(0 == WNMemCmp(this, &_line, sizeof(WNLine3)));
}

WN_BOOL WNLine3::operator != (const WNLine3& _line) const {
    return(0 != WNMemCmp(this, &_line, sizeof(WNLine3)));
}

// Members /////////////////////////////////////////////////////////////////////////////////////////

WN_VOID WNLine3::Zero() {
    point1.Zero();
    point2.Zero();
}

WN_VOID WNLine3::Set(const WN_FLOAT32* _f) {
    point1.x = _f[0];
    point1.y = _f[1];
    point1.z = _f[2];

    point2.x = _f[3];
    point2.y = _f[4];
    point2.z = _f[5];
}

WN_VOID WNLine3::Set(const WNPoint3& _point1, const WNPoint3& _point2) {
    point1 = _point1;
    point2 = _point2;
}

WNVector3 WNLine3::Direction() const {
    return(point2 - point1);
}